home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Informant Complete 1995 - 2000
/
Delphi Informant Complete 1995 to 2000.iso
/
Delphi Informant Magazine Complete Works SOURCE CODE 1998.rar
/
1998
/
Sep
/
di9809am
/
Compont
/
Sample2
/
TapiForm.pas
< prev
Wrap
Pascal/Delphi Source File
|
1998-06-29
|
3KB
|
115 lines
{ This project accompanies the article written by Alan Moore
and Ken Kyler on TAPI basics }
unit TapiForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Mask, ComCtrls, Tapi, TAPIcomp;
type
TTapiCallManager = class(TForm)
Label1: TLabel;
ePhoneNum: TMaskEdit;
btnDial: TButton;
btnHangup: TButton;
kkamTAPI1: TkkamTAPI;
procedure btnDialClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure btnHangupClick(Sender: TObject);
// procedure FormDestroy(Sender: TObject);
public
private
{ Private declarations }
procedure PhoneNumChange;
{ Public declarations }
end;
var
TapiCallManager : TTapiCallManager;
const
Ver = $00010004; // API version accepted (1.4) [Windows 95]
implementation
{$R *.DFM}
procedure TTapiCallManager.btnDialClick(Sender: TObject);
var
DialResult: string;
StringListPlaceHolder : TStringList;
begin
DialResult := kkamTAPI1.Dial;
if DialResult='Success' then
begin
ShowMessage(DialResult);
btnDial.Enabled := False;
btnHangup.Enabled := True;
end;
end;
procedure TTapiCallManager.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
var
StringListPlaceHolder : TStringList;
begin
StringListPlaceHolder := TStringList.Create;
// if the custom call manager was used, make sure to free resources
if kkamTAPI1.LineIsOpen then
CanClose := kkamTAPI1.ShutdownManager;
StringListPlaceHolder.Free
end;
procedure TTapiCallManager.FormCreate(Sender: TObject);
var
S : string;
TheResult : LongInt;
ThePort : THandle;
begin
btnHangup.Enabled := False; // No calls yet!
TheResult := 999; // Initialize to bogus number, just to make certain
PhoneNumChange; //Get Current Value (default)
kkamTAPI1.Dev := 0; // keeping it simple!
if not kkamTAPI1.TAPI_Initialized then
// if we can't initialize, close
begin
ShowMessage('Could not initialize TAPI -- closing down');
Halt;
end
else
begin
if NOT kkamTapi1.OpenLine(False, S) then
begin
ShowMessage('Couldn''t Open a Line; try again later');
exit;
end;
end;
// For pulse dialing, uncomment the following line:
// kkamTapi1.PulseDialing := True;
end;
procedure TTapiCallManager.btnHangupClick(Sender: TObject);
begin
if not kkamTAPI1.ShutdownManager then
ShowMessage('Couldn''t shut TAPI down')
else
begin
btnHangup.Enabled := false; // disable the hangup button
btnDial.Enabled := true; // enable the dial button
end;
end;
procedure TTapiCallManager.PhoneNumChange;
begin
kkamTAPI1.PhoneNumber := ePhoneNum.Text;
end;
end.